import request from '@/utils/request'

export function getMrchList(params) {
    return request({
        url: `/online/authorization/operator/merchant`,
        method: 'GET',
        params
    })
}

export function getMrchDetails(mrchId) {
    return request({
        url: `/online/management/operator/merchant/${mrchId}`,
        method: 'GET'
    })
}

export function getMrchById(mrchId) {
    return request({
        url: `/online/authorization/operator/merchant/${mrchId}`,
        method: 'GET'
    })
}

export function regMrch(data) {
    return request({
        url: `/online/management/operator/merchant`,
        method: 'POST',
        data
    })
}

export function updateMrch(mrchId,data) {
    return request({
        url: `/online/management/operator/merchant/${mrchId}`,
        method: 'POST',
        data
    })
}

export function deleteMrch(mrchId,forceDelete) {
  return request({
    url: `/online/management/operator/merchant/${mrchId}/force-delete/${forceDelete}`,
    method: 'DELETE'
  })
}

export function verifyMrchForDelete(mrchId) {
  return request({
    url: `/online/management/operator/merchant/${mrchId}/verify`,
    method: 'GET'
  })
}

export function getCountryList() {
    return request({
        url: `/online/authorization/country/list`,
        method: 'GET',
        params: {
          status: 1
        }
    })
}

export function addTerminal(devSn, mrchId, data) {
    return request({
        url: `/online/management/operator/merchant/${mrchId}/device/${devSn}/deploy`,
        method: 'POST',
        data
    })
}
export function addTerminalByFile(mrchId, isActive, data) {
    return request({
        url: `/online/management/operator/merchant/${mrchId}/deploy-by-file/${isActive}`,
        method: 'POST',
        data,
        timeout: 10*60*1000
    })
}

export function addTerminalBySnRange(mrchId, isActive, data) {
  return request({
    url: `/online/management/operator/merchant/${mrchId}/deploy-by-sn-range/${isActive}`,
    method: 'POST',
    data,
    timeout: 10*60*1000
  })
}

export function unbindTerminalBySn(mrchId, devSn) {
  return request({
    url: `/online/management/operator/merchant/${mrchId}/unbind/${devSn}`,
    method: 'POST'
  })
}

export function unbindTerminalByFile(mrchId, continueWhenErr, data) {
  return request({
    url: `/online/management/operator/merchant/${mrchId}/unbind-by-file/${continueWhenErr}`,
    method: 'POST',
    data,
    timeout: 10*60*1000
  })
}

export function unbindTerminalBySnRange(mrchId, continueWhenErr, data) {
  return request({
    url: `/online/management/operator/merchant/${mrchId}/unbind-by-sn-range/${continueWhenErr}`,
    method: 'POST',
    data,
    timeout: 10*60*1000
  })
}

export function queryDeployResult(batchNo, params) {
  return request({
    url: `/online/management/operator/merchant/deploy-result/${batchNo}`,
    method: 'GET',
    params
  })
}

export function addTerminalVerifySuccess(mrchId, batchNo, isActive, data) {
  return request({
    url: `/online/management/operator/merchant/${mrchId}/batchNo/${batchNo}/deploy-verify-success/${isActive}`,
    method: 'POST',
    data,
    timeout: 10*60*1000
  })
}


export function queryMerchantPageInfo(params) {
  return request({
    url: `/online/management/operator/merchant`,
    method: 'GET',
    params
  })
}
